<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of User
 *
 * @author Pablo Barrenechea
 */
class MD_NewsCategory
{
    public static function getAll()
    {
    
        return TN_Db::getInstance()->fetchAll("SELECT * FROM news_category ");
    }
    
    public static function getName($id)
    {
    	$category = TN_Db::getInstance()->fetchAll("select title from news_category where id = '$id'");
    	return $category[0]['title'];
    }
    public static function getCategoryById($id)
    {
    	return TN_Db::getInstance()->fetchAll("select * from news_category where id = '$id'");
    }
    public static function add($name,$enabled)
    {
    	TN_Db::getInstance()->insert('news_category', array('title'=> $name, 'enabled' => $enabled));
    }
    
    public static function update($id,$title,$enabled)
    {
    	TN_Db::getInstance()->update('news_category', array( 'title'=> $title, 'enabled' => $enabled) , "id = '$id' ");
    }
    
    public static function delete($id)
    {
    	TN_Db::getInstance()->delete('news_category', "id = '$id' "); 
    }
    
}
?>